package com.ekingstar.lss.commons.supper.utils.query.simple;

import java.io.Serializable;
import java.util.regex.Pattern;

import com.ekingstar.lss.commons.exceptions.QueryUtilsException;
import com.ekingstar.lss.commons.supper.utils.query.LssCount;

/**
 *	公司：金仕达多媒体
 *	作者：童弘成
 *	时间：2011-4-21 下午12:38:56
 *	描述：
 */
public class SimpleCount implements Serializable, LssCount {
	private static final long serialVersionUID = -519263386736597746L;
	public static Pattern check=Pattern.compile("^(sum|count|avg|max|min)\\(\\S+\\)$");
	private String column;
	private String type;
	
	public SimpleCount(){}
	public SimpleCount(String count){
		count=count.trim();
		if(!check.matcher(count).matches()){
			throw new QueryUtilsException("统计格式不正确");
		}
		this.type=count.substring(0,count.indexOf("("));
		this.column=count.substring(count.indexOf("(")+1,count.indexOf(")")).trim();
	}
	
	public String getColumn() {
		return this.column;
	}

	public String getType() {
		return this.type;
	}
	
	public void setColumn(String column){
		this.column=column;
	}
}
